perm filename SEMI.WEB[WEB,ALS] blob
sn#621853 filedate 1981-11-09 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 The following changes are needed to break lines at semi-colons preferably.
C00006 ENDMK
C⊗;
The following changes are needed to break lines at semi-colons preferably.
As a minor cosession to readabilit, we break lines at semi-colons when
ever this is possible, although people are supposed to read the input of
\.{TANGLE} or the \TEX ed output of \.{WEAVE} but not the tangled-up
output.
39/11
@<Globals...@>=
out_buf: array [0..out_buf_size] of ascii_code; {assembled characters}
out_ptr: 0..out_buf_size; {first available place in |out_buf|}
break_ptr: 0..out_buf_size; {last breaking place in |out_buf|}
semi_ptr: 0..out_buf_size; {last semi-colon breaking place in |out_buf|}
112/11
@<Initialize the output buffer@>=
out_state←misc; out_ptr←0; break_ptr←0; out_buf[0]←0; line←1
semi_ptr←0;
122/11
@p procedure flush_buffer; {writes one line to output file}
var k:0..out_buf_size; {index into |out_buf|}
begin
if semi_ptr>0 then break_ptr← break_ptr-semi_ptr
else begin semi_ptr←break_ptr; break_ptr←0; end;
for k←1 to semi_ptr do write(chr(out_buf[k-1]));
write_ln; incr(line);
if line mod 100 = 0 then print('.');
if semi_ptr<out_ptr then
begin if out_buf[semi_ptr]=" " then
incr(semi_ptr); {drop space at break}
for k←semi_ptr to out_ptr-1 do out_buf[k-semi_ptr]←out_buf[k];
end;
out_ptr←out_ptr-semi_ptr; semi_ptr←0;
if out_ptr>line_length then
begin ex_err_print('! Long line must be truncated'); out_ptr←line_length;
end;
end;
138/11
@ @<Empty the last line from the buffer@>=
if (out_state≠misc)∨(out_buf[break_ptr]≠".") then
err_print('! Program didn''t end with period');
semi_ptr←0;
break_ptr←out_ptr; flush_buffer
182/11
@ @p procedure send_out(t:eight_bits; v:sixteen_bits); {outputs $v$ of type $t$}
label restart;
var k: 0..line_length; {index into out_contrib}
begin @<Get the buffer ready for appending the new information@>;
if t≠misc then for k←1 to v do app(out_contrib[k])
else begin app(v); if v=";" then semi_ptr←out_ptr; end;
check_break;
if t≥ident then out_state←num_or_id {|t=ident| or |frac|}
else out_state←misc {|t=str| or |misc|}
end;